package com.UdpRecieve.service.impl;

import com.UdpRecieve.domain.system.SysUser;
import com.UdpRecieve.framework.constant.ServletConstant;
import com.UdpRecieve.service.SysIndexService;
import com.UdpRecieve.service.SysLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SysIndexServiceImpl implements SysIndexService {

    @Autowired
    private SysLoginService sysLoginService;

    /**
     * 获取在线用户详细信息
     * @param id
     * @return
     */
    @Override
    public SysUser getOnlineUser(String id) {
        String userName = null;

        for(Map.Entry<String, String> a: ServletConstant.OnlineUserList.entrySet()){
            if (a.getValue()==id){
                userName = a.getKey();
            }
        }

        SysUser user = new SysUser();
        user.setUserName(userName);
        List<SysUser> sysUserList = sysLoginService.selectUser(user);
        return sysUserList.get(0);
    }
}
